import unittest, requests
from ddt import ddt,file_data


@ddt
class dianshang(unittest.TestCase):

    def setUp(self):
        print("电商")

    def tearDown(self):
        print("结束")

    host = 'http://10.59.9.18'
    userId = None
    sessionId = None

    # 登录
    @file_data("user.json")

    def test_001(self,email,pwd,expect):
        print(expect)
        url = dianshang.host + "/movieApi/user/v2/login"
        data = {"email": email, "pwd": pwd}
        r1 = requests.post(url=url,
                           params=data)
        print(r1.json())
        dianshang.userId = r1.json()["result"]["userId"]
        dianshang.sessionId = r1.json()["result"]["sessionId"]
        print(dianshang.userId, dianshang.sessionId)

    def test_002(self):
        url = dianshang.host + "/movieApi/cinema/v1/findNearbyCinemas"
        headers = {"userId": str(dianshang.userId), "sessionId": str(dianshang.sessionId)}
        params = {"longitude":"116.30551391385724","latitude":"40.04571807462411","page":1,"count":5,}
        r2 = requests.get(url = url,
                          headers = headers,
                          params = params)
        print(r2.json())


if __name__ == '__main__':
    unittest.main()


